package kr.hkit.Powerjava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGenerater {

	private int[] arr;
	private static final int SIZE=6;
	private Random rnd;
	
	public LottoGenerater() {
		arr = new int[LottoGenerater.SIZE];
		rnd = new Random();
	}
	
	public void getLottoNum() {
		int num = -1;
		for (int i = 0; i < arr.length; i++) {
			num = getNum();
			if(isFind(num)){
//				num=getNum();
				i--;
			}else{
				arr[i]=num;
			}
			
		}
	}
	
	public int getNum() {
		return rnd.nextInt(45)+1;
	}
	
	public boolean isFind(int searchNum) {
		boolean isEquals=false;
		for (int i = 0; i < arr.length; i++) {
			if (searchNum == arr[i]){
				isEquals=true;
				break;
			}
		}	
		System.out.println(isEquals);
		return isEquals;
	}
	
	
	
	
	
	
	@Override
	public String toString() {
		return String.format("LottoGenerater %s", Arrays.toString(arr));
	}

	public static void main(String[] args) {
		LottoGenerater lo = new LottoGenerater();
		lo.getLottoNum();
		System.out.println(lo);
		
	}
	
}
